/*
 * window trial auth info from 14443A card
 */

#ifndef WINDOW_TRIAL_H
#define WINDOW_TRIAL_H

#include "gkt_types.h"
#include "gkt_rfid.h"


#ifdef __cplusplus
extern "C" {
#endif

#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE

enum {
	WINDOW_TRIAL_AUTH_MODE_TEMPORARY = 0,
	WINDOW_TRIAL_AUTH_MODE_PERPETUAL,
	WINDOW_TRIAL_AUTH_MODE_MAX
};

#if defined(GKT_CONFIG_DOOR_TRIAL_AUTH_COUNT_MAX)
#define WINDOW_TRIAL_AUTH_COUNT_MAX GKT_CONFIG_DOOR_TRIAL_AUTH_COUNT_MAX//(0x7FFF)
#else
#define WINDOW_TRIAL_AUTH_COUNT_MAX 1500
#endif
#if defined(GKT_CONFIG_DOOR_TRIAL_AUTH_COUNT_MIN)
#define WINDOW_TRIAL_AUTH_COUNT_MIN GKT_CONFIG_DOOR_TRIAL_AUTH_COUNT_MIN
#else
#define WINDOW_TRIAL_AUTH_COUNT_MIN 1400
#endif

#define WINDOW_TRIAL_AUTH_MAGIC	0x3D71A13C
typedef struct _window_trial_auth {
	uint32_t	magic;
	uint16_t 	auth_mode;
	uint16_t	auth_count_max;
	uint16_t	auth_count_min;
	uint16_t	crc16;	/* data crc, CRC16_CCITT_FALSE, POLY = 0x1021, INIT = 0xFFFF */
	uint16_t	rfu_0;
	uint16_t	rfu_1;	/* reserved */
} window_trial_auth_s;

int window_trial_update_auth(gkt_rfid_info_s *rfid_info);

#endif

#ifdef __cplusplus
}
#endif
 
#endif

